//
//  BIZOfficialAppendQuestionCell.m
//  biz
//
//  Created by zhangfuwei on 2017/7/11.
//  Copyright © 2017年 jieshuibao. All rights reserved.
//

#import "BIZOfficialAppendQuestionCell.h"
#import "BIZConsultRecordModel.h"

@interface BIZOfficialAppendQuestionCell ()

/** appendImgV */
@property (nonatomic, strong) UIButton *appendQuestionTitleButton;

/** questionContent */
@property (nonatomic, strong) UILabel *appendQuestionLabel;
/** indexPath */
@property (nonatomic, strong) NSIndexPath *indexPath;

@end
@implementation BIZOfficialAppendQuestionCell {
    UIView *_topGrayView;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initSubViews];
        
    }
    return self;
}

- (void)initSubViews {
    _topGrayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Main_Screen_Width, 10)];
    _topGrayView.backgroundColor = [UIColor zfw_ColorWithHex:0xf9f9f9 alpha:1.0];
    
    [self.contentView addSubview:_topGrayView];
    [self.contentView addSubview:self.appendQuestionTitleButton];
    [self.contentView addSubview:self.appendQuestionLabel];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.appendQuestionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(60, 15, 15, 15)).priorityHigh();
    }];
    
}

#pragma mark - class method
+ (BIZOfficialAppendQuestionCell *)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
{
    BIZOfficialAppendQuestionCell *cell = [tableView dequeueReusableCellWithIdentifier:kOfficialAppendQuestionCellID forIndexPath:indexPath];
    cell.indexPath = indexPath;
    return cell;
}

#pragma mark -- set方法
- (void)setAppendQuestionModel:(BIZConsultRecordModel *)appendQuestionModel {
    _appendQuestionModel = appendQuestionModel;
    if (appendQuestionModel == nil) {
        return;
    }
    //  此处使用indexpath 和 statge 综合判断是否需要隐藏追问按钮,是第几次追问
    NSString *question = appendQuestionModel.firstAsk;
    switch (_indexPath.row) {
        case 2:
            question = appendQuestionModel.firstAsk;
            break;
        case 4:
            question = appendQuestionModel.secondAsk;
            break;
        case 6:
            question = appendQuestionModel.thirdAsk;
            break;
        default:
            break;
    }
    _appendQuestionLabel.text = question;
    [self layoutIfNeeded];
}

#pragma mark -- lazyload
- (UIButton *)appendQuestionTitleButton {
    if (!_appendQuestionTitleButton) {
        _appendQuestionTitleButton = [[UIButton alloc] initWithFrame:CGRectMake(15, 23, 70, 25)];
        _appendQuestionTitleButton.backgroundColor = [UIColor zfw_ColorWithHex:0x229efe alpha:1.0];
        _appendQuestionTitleButton.layer.cornerRadius = 10.f;
        _appendQuestionTitleButton.layer.masksToBounds = YES;
        [_appendQuestionTitleButton setTitle:@"用户追问" forState:UIControlStateNormal];
        [_appendQuestionTitleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _appendQuestionTitleButton.titleLabel.font = [UIFont fontWithName:CHINESE_FONT_NAME size:13];
    }
    return _appendQuestionTitleButton;
}

- (UILabel *)appendQuestionLabel {
    if (!_appendQuestionLabel) {
        _appendQuestionLabel = [[UILabel alloc] init];
        _appendQuestionLabel.numberOfLines = 0;
        _appendQuestionLabel.textColor = [UIColor zfw_ColorWithHex:0x000000 alpha:1.0];
        _appendQuestionLabel.font = [UIFont fontWithName:CHINESE_FONT_NAME size:14];
    }
    return _appendQuestionLabel;
}

@end
